package com.woniu.controller;

import com.woniu.common.core.domain.AjaxResult;
import com.woniu.model.LoginModel;
import com.woniu.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨光 微信号:tolryg
 * @time 15:27
 */
@RestController
public class LoginController {


    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginModel loginModel){
        System.out.println("loginModel = " + loginModel);

        String jwt = loginService.login(loginModel);
        AjaxResult ajaxResult = AjaxResult.success("ok", jwt);
        return ajaxResult;
    }

    @PostMapping("web/login")
    public AjaxResult weblogin(@RequestBody LoginModel loginModel){
        System.out.println("loginModel = " + loginModel);

        String jwt = loginService.weblogin(loginModel);
        AjaxResult ajaxResult = AjaxResult.success("ok", jwt);
        return ajaxResult;
    }
}
